package com.travelbid.admin.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.web.struts.ActionSupport;
import com.travelbid.admin.dao.TProjetDAO;
import com.travelbid.admin.pojo.TProjet;
import com.travelbid.admin.struts.form.AddProjetForm;

public class PreEditProjetAction extends ActionSupport {
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
	
		Integer projetId = new Integer(request.getParameter("projetId"));
		TProjetDAO dao = (TProjetDAO)getWebApplicationContext().getBean("TProjetDAO");
		
		AddProjetForm pForm = new AddProjetForm();
		TProjet projet = dao.findById(new Integer(projetId));
		
		pForm.setTitle(projet.getTitle());
		pForm.setContent(projet.getContent());
		
		request.setAttribute("projetForm", pForm);
		request.setAttribute("projet", projet);
		return mapping.findForward("EditProjet");
	}
}